<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of strsplit</title>
  <meta name="keywords" content="strsplit">
  <meta name="description" content="Split string into pieces.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">source</a> &gt; strsplit.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for source&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>strsplit
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Split string into pieces.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function parts = strsplit( splitstr, str, option ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">Split string into pieces.

STRSPLIT(SPLITSTR, STR, OPTION) splits the string STR at every occurrence
of SPLITSTR and returns the result as a cell array of strings.  By default,
SPLITSTR is not included in the output.

STRSPLIT(SPLITSTR, STR, OPTION) can be used to control how SPLITSTR is
included in the output.  If OPTION is 'include', SPLITSTR will be included
as a separate string.  If OPTION is 'append', SPLITSTR will be appended to
each output string, as if the input string was split at the position right
after the occurrence SPLITSTR.  If OPTION is 'omit', SPLITSTR will not be
included in the output.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="convertToSdp.html" class="code" title="function [ alfa ] = convertToSdp( alfa )">convertToSdp</a>	Converts Syms variables into sdpvar().</li><li><a href="extendedAffine.html" class="code" title="function [ newA ] = extendedAffine( A, n, m, hState, d )">extendedAffine</a>	Calculate the Extended Affine Matrix of matrix A.</li><li><a href="generateCoefficientEquationFromString.html" class="code" title="function [ theCoefficient ] = generateCoefficientEquationFromString( chr )">generateCoefficientEquationFromString</a>	Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.</li><li><a href="generateSdpVarL.html" class="code" title="function [ sdpL ] = generateSdpVarL( L, numberOfLToBeDone )">generateSdpVarL</a>	Generate a number equal to numberOfLToBeDone of sdpvar() Matrix starting from matrix L.</li><li><a href="getCoefficientFromString.html" class="code" title="function [ coefficient ] = getCoefficientFromString( chr )">getCoefficientFromString</a>	Take the coefficients of variables that don't have, for construction, any divisor.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%Split string into pieces.</span>
0002 <span class="comment">%</span>
0003 <span class="comment">%STRSPLIT(SPLITSTR, STR, OPTION) splits the string STR at every occurrence</span>
0004 <span class="comment">%of SPLITSTR and returns the result as a cell array of strings.  By default,</span>
0005 <span class="comment">%SPLITSTR is not included in the output.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">%STRSPLIT(SPLITSTR, STR, OPTION) can be used to control how SPLITSTR is</span>
0008 <span class="comment">%included in the output.  If OPTION is 'include', SPLITSTR will be included</span>
0009 <span class="comment">%as a separate string.  If OPTION is 'append', SPLITSTR will be appended to</span>
0010 <span class="comment">%each output string, as if the input string was split at the position right</span>
0011 <span class="comment">%after the occurrence SPLITSTR.  If OPTION is 'omit', SPLITSTR will not be</span>
0012 <span class="comment">%included in the output.</span>
0013 
0014 <span class="comment">%   Author:      Peter J. Acklam</span>
0015 <span class="comment">%   Time-stamp:  2004-09-22 08:48:01 +0200</span>
0016 <span class="comment">%   E-mail:      pjacklam@online.no</span>
0017 <span class="comment">%   URL:         http://home.online.no/~pjacklam</span>
0018 
0019 <a name="_sub0" href="#_subfunctions" class="code">function parts = strsplit( splitstr, str, option )</a>
0020 
0021    nargsin = nargin;
0022    error(nargchk(2, 3, nargsin));
0023    <span class="keyword">if</span> nargsin &lt; 3
0024       option = <span class="string">'omit'</span>;
0025    <span class="keyword">else</span>
0026       option = lower(option);
0027    <span class="keyword">end</span>
0028 
0029    splitlen = length(splitstr);
0030    parts = {};
0031 
0032    <span class="keyword">while</span> 1
0033 
0034       k = strfind(str, splitstr);
0035       <span class="keyword">if</span> isempty(k)
0036          parts{end+1} = str;
0037          <span class="keyword">break</span>
0038       <span class="keyword">end</span>
0039 
0040       <span class="keyword">switch</span> option
0041          <span class="keyword">case</span> <span class="string">'include'</span>
0042             parts(end+1:end+2) = {str(1:k(1)-1), splitstr};
0043          <span class="keyword">case</span> <span class="string">'append'</span>
0044             parts{end+1} = str(1 : k(1)+splitlen-1);
0045          <span class="keyword">case</span> <span class="string">'omit'</span>
0046             parts{end+1} = str(1 : k(1)-1);
0047          <span class="keyword">otherwise</span>
0048             error([<span class="string">'Invalid option string -- '</span>, option]);
0049       <span class="keyword">end</span>
0050 
0051 
0052       str = str(k(1)+splitlen : end);
0053 
0054    <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 12-Oct-2009 21:15:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>